#include "stdafx.h"
#pragma once
//-------------------------------------------------------------------------------------------------
//ImageTypeProp.h  - a property for a particular ImageType 
//	typically an ImageType has one or more properties that a user can edit in the Property Window (top part)           
//-------------------------------------------------------------------------------------------------
//FreeBSD License
//Copyright 2011 Will Stott All rights reserved.
//
//Redistribution and use in source and binary forms, with or without modification, are
//permitted provided that the following conditions are met:
//
//   1. Redistributions of source code must retain the above copyright notice, this list of
//      conditions and the following disclaimer.
//
//   2. Redistributions in binary form must reproduce the above copyright notice, this list
//      of conditions and the following disclaimer in the documentation and/or other materials
//      provided with the distribution.
//
//THIS SOFTWARE IS PROVIDED BY Will Stott ``AS IS'' AND ANY EXPRESS OR IMPLIED
//WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
//FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Will Stott OR
//CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
//CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
//SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
//ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
//ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//The views and conclusions contained in the software and documentation are those of the
//authors and should not be interpreted as representing official policies, either expressed
//or implied, of Will Stott.
//
//----Authors--------------------------------------------------------------------------------------
//created by: will.stott@ucl.ac.uk Sept 2011
//
//----Comments-------------------------------------------------------------------------------------
//
// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the IMAGEPROCLIB_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// IMAGEPROCLIBAPI functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
//--------------------------------------------------------------------------------------------------

#ifdef IMAGEPROCLIB_EXPORTS
#define IMAGEPROCLIBAPI __declspec(dllexport)
#else
#define IMAGEPROCLIBAPI __declspec(dllimport)
#endif

#include <string>

#include "TinyXmlLib.h"

#include "Observer.h"

	//<Header>
	//   <ImageTypes>Types of Images found in Static Image Review
    //        <ImageType>Ovary TS</ImageType>
	//				<ImageTypeProps>Properties for this type of image
	//					<ImageTypeProp Type="ImagePropTextLines" Control="CEdit" ValMin="-1" ValMax="500" Prompt="Enter text to describe image">Notes</ImageTypeProp>
	//					<ImageTypeProp Type="ImagePropInteger" Control="Spin" ValMin="1" ValMax="3" Prompt="Enter quality score image">Quality</ImageTypeProp>
	//				</ImageTypeProps>
	//				<ImageTypeImageObjects>Types of Objects found in this type of image
    //					<ImageTypeImageObject Base="PtShape" PtCode="INC" PenColour="0:0:0" ExpertMaxObjs="-1" MenuName="Inc Cyst">Inclusion Cyst
    //                    <ImageTypeProps>Properties of an Inclusion Cyst Image Object
    //                        <ImageTypeProp Type="ImagePropTextLines" Control="CEdit" ValMin="-1" ValMax="500" Prompt="Enter text to describe Inclusion Cyst">Notes</ImageTypeProp>
	//					      <ImageTypeProp Type="ImagePropInteger" Control="Spin" ValMin="1" ValMax="3" Prompt="Enter quality score for Inclusion Cyst">Quality</ImageTypeProp>
	//					  </ImageTypeProps>
	//					</ImageTypeImageObject>
	//					... other ImageTypeImageObjects go here
	//				<ImageTypeImageObjects>
	//	 </ImageTypes>		
	//   ...
	//<Header>
	//<Body>
	//   <Images>
	//		<Image ImageType="Ovary TS" Notes="this is a nice clear image" Quality="1" >1.2.826.999999.1.9999.1.20080115012154575.1.3.0 
	//			<ImageObject Type="Inclusion Cyst" Note="this is a poor example" Quality="3" PtCnt="76" y1="176" x1="346" ... y76="176" x76="346">1316593822</ImageObject>
	//			<ImageObject Type="Inclusion Cyst" Note="this is a better example" Quality="2" PtCnt="65" y1="21" x1="234"... y65="21" x65="234" >1316593823</ImageObject>
	//		</Image>
	//		...
	//	 </Images>
	//</Body>

//<ImageTypeProp Type="PropTextLines" Control="CEdit" ValMin="-1" ValMax="500" Prompt="Enter text to describe image">Notes</ImageTypeProp>

class IMAGEPROCLIBAPI ImageTypeProp
{
public:
	static const char * const xmlType;
	static const char * const xmlControl;
	static const char * const xmlValMin;
	static const char * const xmlValMax;
	static const char * const xmlPrompt;
	static const char * const xmlDefaultValue;

private:
	std::string		_OwnerType;			//ImageType or ImageTypeImageObject - just set the name for now, consider making this a pointer to the actual object
	std::string		_Name;				//Notes
	std::string		_Type;				//Type="PropTextLines"
	std::string		_Control;			//Control="CEdit"
	std::string		_Prompt;			//Prompt="Enter text to describe image"
	int				_ValMin;			//ValMin="-1"
	int				_ValMax;			//ValMax="500"
	std::string		_DefaultValue;		//default value if this properties isn't found in xml element <image>

public:
	ImageTypeProp(void);
	virtual ~ImageTypeProp(void);

	static	ImageTypeProp*CreateImageTypeProp(TiXmlElement *xmlImageTypeProp, const char *ownerTypeName);

//	bool	        IsOwnerImageType() { return (_OwnerType == ImageType::xmlImageType) ? true : false; }
	const char     *GetName() { return _Name.c_str(); }
	const char     *GetType() { return _Type.c_str(); }
	const char     *GetControl() { return _Control.c_str(); }
	int				GetValMin() { return _ValMin; }
	int				GetValMax() { return _ValMax; }
	const char     *GetPrompt() { return _Prompt.c_str(); }
	const char     *GetDefaultValue() { return _DefaultValue.c_str(); }


private:		//as set by CreateImageTypeProp()
	bool			SetOwnerTypeName(const char *ownerTypeName);
	void			SetName(const char *name) {  _Name = name; }
	void			SetType(const char *type) { _Type = type; }
	void			SetControl(const char *control) { _Control = control; }
	void			SetValMin(const char *valMin);
	void			SetValMax(const char *valMax);
	void			SetPrompt(const char *prompt) { _Prompt = prompt; }
	void			SetDefaultValue(const char *val) {_DefaultValue = val; }

};


//-------------------------------------------------------------------------------------------------
//			E N D   O F   F I L E
//-------------------------------------------------------------------------------------------------

